package com.javacoo.swing.jxbrowser.content;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import com.javacoo.swing.jxbrowser.BaseBrowser;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

/**
 * UserAgent
 * <li></li>
 * 在创建任何浏览器实例之前，只能修改一次用户代理字符串。您可以使用BrowserPreferences.setUserAgent（String userAgent）方法或通过jxbrowser.chromium.user-agent Java System属性提供您自己的用户代理字符串
 * @author: duanyong@jccfc.com
 * @since: 2020/9/25 10:30
 */
public class UserAgent extends BaseBrowser {
    public static void main(String[] args) {
        // It's very important to configure user-agent string
        // before any Browser instance is created.
        BrowserPreferences.setUserAgent("My User Agent String");

        Browser browser = new Browser();
        BrowserView browserView = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(browserView, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        browser.loadURL(BASE_URL);
    }
}
